package other.Other_homework;

import java.util.ArrayList;
import java.util.Random;

public class Random_Red_packet implements Red_packet {
    @Override
    public ArrayList<Integer> divide(int Summoney, int count) {
        ArrayList<Integer> list = new ArrayList<>();
        int balance=Summoney,red_money;
        Random rs = new Random();
        for (int i = 0; i < count-1; i++) {
            red_money=rs.nextInt(balance);
            while(red_money>=(Summoney/2))
            {
                red_money=rs.nextInt(balance);
            }
            list.add(red_money);
            balance-=red_money;
        }
        list.add(balance);
        return list;
    }
}
